// $ANTLR 3.3 Nov 30, 2010 12:45:30 D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g 2013-09-13 02:37:07

package org.moflon.moca.blip.parser; 
import java.util.Collection;
import Moca.MocaFactory;
import Moca.Problem;
import Moca.ProblemType;


import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;


import org.antlr.runtime.tree.*;

public class BlipParser extends Parser {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "SLASH", "COLON", "AT", "MINUS", "LBRACE", "RBRACE", "BRACKETS", "COMMA", "SERVICETYPE", "CR", "LF", "SPACE", "TAB", "LETTER", "DIGIT", "STRING", "WS", "COMMENT", "APPLICATION", "ATTR", "MODEL", "MODEL_ATTR", "SERVICE", "T", "ATTRIBUTE"
    };
    public static final int EOF=-1;
    public static final int SLASH=4;
    public static final int COLON=5;
    public static final int AT=6;
    public static final int MINUS=7;
    public static final int LBRACE=8;
    public static final int RBRACE=9;
    public static final int BRACKETS=10;
    public static final int COMMA=11;
    public static final int SERVICETYPE=12;
    public static final int CR=13;
    public static final int LF=14;
    public static final int SPACE=15;
    public static final int TAB=16;
    public static final int LETTER=17;
    public static final int DIGIT=18;
    public static final int STRING=19;
    public static final int WS=20;
    public static final int COMMENT=21;
    public static final int APPLICATION=22;
    public static final int ATTR=23;
    public static final int MODEL=24;
    public static final int MODEL_ATTR=25;
    public static final int SERVICE=26;
    public static final int T=27;
    public static final int ATTRIBUTE=28;

    // delegates
    // delegators


        public BlipParser(TokenStream input) {
            this(input, new RecognizerSharedState());
        }
        public BlipParser(TokenStream input, RecognizerSharedState state) {
            super(input, state);
             
        }
        
    protected TreeAdaptor adaptor = new CommonTreeAdaptor();

    public void setTreeAdaptor(TreeAdaptor adaptor) {
        this.adaptor = adaptor;
    }
    public TreeAdaptor getTreeAdaptor() {
        return adaptor;
    }

    public String[] getTokenNames() { return BlipParser.tokenNames; }
    public String getGrammarFileName() { return "D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g"; }


      public Collection<Problem> problems = new ArrayList<Problem>();

          public void displayRecognitionError(String[] tokenNames,
                                            RecognitionException e) {
              Problem problem = MocaFactory.eINSTANCE.createProblem();
              int line  = e.line;
              int charPos = e.charPositionInLine;
              int tokenLenght = 1;
              Token token = e.token;
              if(token != null) 
                tokenLenght = token.getText().length();
                      
              
              problem.setType(ProblemType.ERROR);
              problem.setLine(line); 
              problem.setCharacterPositionStart(charPos); 
              problem.setCharacterPositionEnd(charPos+tokenLenght);
              problem.setMessage("Parser: " + getErrorMessage(e, tokenNames));
              
              problems.add(problem);
              super.displayRecognitionError(tokenNames, e);
        }


    public static class main_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "main"
    // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:55:1: main : ( applicationPart )+ -> ^( T[\"Application\"] ( applicationPart )+ ) ;
    public final BlipParser.main_return main() throws RecognitionException {
        BlipParser.main_return retval = new BlipParser.main_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        BlipParser.applicationPart_return applicationPart1 = null;


        RewriteRuleSubtreeStream stream_applicationPart=new RewriteRuleSubtreeStream(adaptor,"rule applicationPart");
        try {
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:55:5: ( ( applicationPart )+ -> ^( T[\"Application\"] ( applicationPart )+ ) )
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:55:7: ( applicationPart )+
            {
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:55:7: ( applicationPart )+
            int cnt1=0;
            loop1:
            do {
                int alt1=2;
                int LA1_0 = input.LA(1);

                if ( ((LA1_0>=AT && LA1_0<=MINUS)||LA1_0==SERVICETYPE) ) {
                    alt1=1;
                }


                switch (alt1) {
            	case 1 :
            	    // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:55:7: applicationPart
            	    {
            	    pushFollow(FOLLOW_applicationPart_in_main98);
            	    applicationPart1=applicationPart();

            	    state._fsp--;

            	    stream_applicationPart.add(applicationPart1.getTree());

            	    }
            	    break;

            	default :
            	    if ( cnt1 >= 1 ) break loop1;
                        EarlyExitException eee =
                            new EarlyExitException(1, input);
                        throw eee;
                }
                cnt1++;
            } while (true);



            // AST REWRITE
            // elements: applicationPart
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 56:2: -> ^( T[\"Application\"] ( applicationPart )+ )
            {
                // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:56:5: ^( T[\"Application\"] ( applicationPart )+ )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(T, "Application"), root_1);

                if ( !(stream_applicationPart.hasNext()) ) {
                    throw new RewriteEarlyExitException();
                }
                while ( stream_applicationPart.hasNext() ) {
                    adaptor.addChild(root_1, stream_applicationPart.nextTree());

                }
                stream_applicationPart.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "main"

    public static class applicationPart_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "applicationPart"
    // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:58:1: applicationPart : ( attribute -> attribute | model -> model | service -> service );
    public final BlipParser.applicationPart_return applicationPart() throws RecognitionException {
        BlipParser.applicationPart_return retval = new BlipParser.applicationPart_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        BlipParser.attribute_return attribute2 = null;

        BlipParser.model_return model3 = null;

        BlipParser.service_return service4 = null;


        RewriteRuleSubtreeStream stream_model=new RewriteRuleSubtreeStream(adaptor,"rule model");
        RewriteRuleSubtreeStream stream_service=new RewriteRuleSubtreeStream(adaptor,"rule service");
        RewriteRuleSubtreeStream stream_attribute=new RewriteRuleSubtreeStream(adaptor,"rule attribute");
        try {
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:58:16: ( attribute -> attribute | model -> model | service -> service )
            int alt2=3;
            switch ( input.LA(1) ) {
            case AT:
                {
                alt2=1;
                }
                break;
            case MINUS:
                {
                alt2=2;
                }
                break;
            case SERVICETYPE:
                {
                alt2=3;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("", 2, 0, input);

                throw nvae;
            }

            switch (alt2) {
                case 1 :
                    // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:58:18: attribute
                    {
                    pushFollow(FOLLOW_attribute_in_applicationPart117);
                    attribute2=attribute();

                    state._fsp--;

                    stream_attribute.add(attribute2.getTree());


                    // AST REWRITE
                    // elements: attribute
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 58:28: -> attribute
                    {
                        adaptor.addChild(root_0, stream_attribute.nextTree());

                    }

                    retval.tree = root_0;
                    }
                    break;
                case 2 :
                    // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:58:43: model
                    {
                    pushFollow(FOLLOW_model_in_applicationPart125);
                    model3=model();

                    state._fsp--;

                    stream_model.add(model3.getTree());


                    // AST REWRITE
                    // elements: model
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 58:49: -> model
                    {
                        adaptor.addChild(root_0, stream_model.nextTree());

                    }

                    retval.tree = root_0;
                    }
                    break;
                case 3 :
                    // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:58:60: service
                    {
                    pushFollow(FOLLOW_service_in_applicationPart133);
                    service4=service();

                    state._fsp--;

                    stream_service.add(service4.getTree());


                    // AST REWRITE
                    // elements: service
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 58:68: -> service
                    {
                        adaptor.addChild(root_0, stream_service.nextTree());

                    }

                    retval.tree = root_0;
                    }
                    break;

            }
            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "applicationPart"

    public static class attribute_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "attribute"
    // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:60:1: attribute : AT name= STRING value= STRING -> ^( ATTRIBUTE $name $value) ;
    public final BlipParser.attribute_return attribute() throws RecognitionException {
        BlipParser.attribute_return retval = new BlipParser.attribute_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token name=null;
        Token value=null;
        Token AT5=null;

        Object name_tree=null;
        Object value_tree=null;
        Object AT5_tree=null;
        RewriteRuleTokenStream stream_AT=new RewriteRuleTokenStream(adaptor,"token AT");
        RewriteRuleTokenStream stream_STRING=new RewriteRuleTokenStream(adaptor,"token STRING");

        try {
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:60:10: ( AT name= STRING value= STRING -> ^( ATTRIBUTE $name $value) )
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:60:12: AT name= STRING value= STRING
            {
            AT5=(Token)match(input,AT,FOLLOW_AT_in_attribute144);  
            stream_AT.add(AT5);

            name=(Token)match(input,STRING,FOLLOW_STRING_in_attribute148);  
            stream_STRING.add(name);

            value=(Token)match(input,STRING,FOLLOW_STRING_in_attribute152);  
            stream_STRING.add(value);



            // AST REWRITE
            // elements: name, value
            // token labels: name, value
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleTokenStream stream_name=new RewriteRuleTokenStream(adaptor,"token name",name);
            RewriteRuleTokenStream stream_value=new RewriteRuleTokenStream(adaptor,"token value",value);
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 61:2: -> ^( ATTRIBUTE $name $value)
            {
                // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:61:5: ^( ATTRIBUTE $name $value)
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(ATTRIBUTE, "ATTRIBUTE"), root_1);

                adaptor.addChild(root_1, stream_name.nextNode());
                adaptor.addChild(root_1, stream_value.nextNode());

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "attribute"

    public static class model_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "model"
    // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:63:1: model : MINUS name= STRING LBRACE ( modelAttr )* RBRACE -> ^( T[\"Model\"] ^( ATTRIBUTE T[\"name\"] $name) ( modelAttr )* ) ;
    public final BlipParser.model_return model() throws RecognitionException {
        BlipParser.model_return retval = new BlipParser.model_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token name=null;
        Token MINUS6=null;
        Token LBRACE7=null;
        Token RBRACE9=null;
        BlipParser.modelAttr_return modelAttr8 = null;


        Object name_tree=null;
        Object MINUS6_tree=null;
        Object LBRACE7_tree=null;
        Object RBRACE9_tree=null;
        RewriteRuleTokenStream stream_RBRACE=new RewriteRuleTokenStream(adaptor,"token RBRACE");
        RewriteRuleTokenStream stream_MINUS=new RewriteRuleTokenStream(adaptor,"token MINUS");
        RewriteRuleTokenStream stream_STRING=new RewriteRuleTokenStream(adaptor,"token STRING");
        RewriteRuleTokenStream stream_LBRACE=new RewriteRuleTokenStream(adaptor,"token LBRACE");
        RewriteRuleSubtreeStream stream_modelAttr=new RewriteRuleSubtreeStream(adaptor,"rule modelAttr");
        try {
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:63:6: ( MINUS name= STRING LBRACE ( modelAttr )* RBRACE -> ^( T[\"Model\"] ^( ATTRIBUTE T[\"name\"] $name) ( modelAttr )* ) )
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:63:8: MINUS name= STRING LBRACE ( modelAttr )* RBRACE
            {
            MINUS6=(Token)match(input,MINUS,FOLLOW_MINUS_in_model172);  
            stream_MINUS.add(MINUS6);

            name=(Token)match(input,STRING,FOLLOW_STRING_in_model176);  
            stream_STRING.add(name);

            LBRACE7=(Token)match(input,LBRACE,FOLLOW_LBRACE_in_model178);  
            stream_LBRACE.add(LBRACE7);

            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:63:33: ( modelAttr )*
            loop3:
            do {
                int alt3=2;
                int LA3_0 = input.LA(1);

                if ( (LA3_0==STRING) ) {
                    alt3=1;
                }


                switch (alt3) {
            	case 1 :
            	    // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:63:33: modelAttr
            	    {
            	    pushFollow(FOLLOW_modelAttr_in_model180);
            	    modelAttr8=modelAttr();

            	    state._fsp--;

            	    stream_modelAttr.add(modelAttr8.getTree());

            	    }
            	    break;

            	default :
            	    break loop3;
                }
            } while (true);

            RBRACE9=(Token)match(input,RBRACE,FOLLOW_RBRACE_in_model183);  
            stream_RBRACE.add(RBRACE9);



            // AST REWRITE
            // elements: modelAttr, name
            // token labels: name
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleTokenStream stream_name=new RewriteRuleTokenStream(adaptor,"token name",name);
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 64:2: -> ^( T[\"Model\"] ^( ATTRIBUTE T[\"name\"] $name) ( modelAttr )* )
            {
                // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:64:5: ^( T[\"Model\"] ^( ATTRIBUTE T[\"name\"] $name) ( modelAttr )* )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(T, "Model"), root_1);

                // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:64:18: ^( ATTRIBUTE T[\"name\"] $name)
                {
                Object root_2 = (Object)adaptor.nil();
                root_2 = (Object)adaptor.becomeRoot((Object)adaptor.create(ATTRIBUTE, "ATTRIBUTE"), root_2);

                adaptor.addChild(root_2, (Object)adaptor.create(T, "name"));
                adaptor.addChild(root_2, stream_name.nextNode());

                adaptor.addChild(root_1, root_2);
                }
                // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:64:47: ( modelAttr )*
                while ( stream_modelAttr.hasNext() ) {
                    adaptor.addChild(root_1, stream_modelAttr.nextTree());

                }
                stream_modelAttr.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "model"

    public static class modelAttr_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "modelAttr"
    // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:66:1: modelAttr : name= STRING COLON type= STRING (isArray= BRACKETS )? -> ^( $name ^( ATTRIBUTE T[\"type\"] $type) ) ;
    public final BlipParser.modelAttr_return modelAttr() throws RecognitionException {
        BlipParser.modelAttr_return retval = new BlipParser.modelAttr_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token name=null;
        Token type=null;
        Token isArray=null;
        Token COLON10=null;

        Object name_tree=null;
        Object type_tree=null;
        Object isArray_tree=null;
        Object COLON10_tree=null;
        RewriteRuleTokenStream stream_COLON=new RewriteRuleTokenStream(adaptor,"token COLON");
        RewriteRuleTokenStream stream_BRACKETS=new RewriteRuleTokenStream(adaptor,"token BRACKETS");
        RewriteRuleTokenStream stream_STRING=new RewriteRuleTokenStream(adaptor,"token STRING");

        try {
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:66:10: (name= STRING COLON type= STRING (isArray= BRACKETS )? -> ^( $name ^( ATTRIBUTE T[\"type\"] $type) ) )
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:66:12: name= STRING COLON type= STRING (isArray= BRACKETS )?
            {
            name=(Token)match(input,STRING,FOLLOW_STRING_in_modelAttr213);  
            stream_STRING.add(name);

            COLON10=(Token)match(input,COLON,FOLLOW_COLON_in_modelAttr215);  
            stream_COLON.add(COLON10);

            type=(Token)match(input,STRING,FOLLOW_STRING_in_modelAttr219);  
            stream_STRING.add(type);

            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:66:42: (isArray= BRACKETS )?
            int alt4=2;
            int LA4_0 = input.LA(1);

            if ( (LA4_0==BRACKETS) ) {
                alt4=1;
            }
            switch (alt4) {
                case 1 :
                    // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:66:43: isArray= BRACKETS
                    {
                    isArray=(Token)match(input,BRACKETS,FOLLOW_BRACKETS_in_modelAttr224);  
                    stream_BRACKETS.add(isArray);


                    }
                    break;

            }



            // AST REWRITE
            // elements: type, name
            // token labels: name, type
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleTokenStream stream_name=new RewriteRuleTokenStream(adaptor,"token name",name);
            RewriteRuleTokenStream stream_type=new RewriteRuleTokenStream(adaptor,"token type",type);
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 67:2: -> ^( $name ^( ATTRIBUTE T[\"type\"] $type) )
            {
                // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:67:5: ^( $name ^( ATTRIBUTE T[\"type\"] $type) )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot(stream_name.nextNode(), root_1);

                // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:67:13: ^( ATTRIBUTE T[\"type\"] $type)
                {
                Object root_2 = (Object)adaptor.nil();
                root_2 = (Object)adaptor.becomeRoot((Object)adaptor.create(ATTRIBUTE, "ATTRIBUTE"), root_2);

                adaptor.addChild(root_2, (Object)adaptor.create(T, "type"));
                adaptor.addChild(root_2, stream_type.nextNode());

                adaptor.addChild(root_1, root_2);
                }

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "modelAttr"

    public static class service_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "service"
    // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:69:1: service : type= SERVICETYPE name= STRING ( attribute )* LBRACE ( servicePart )* RBRACE -> ^( SERVICE $type ( attribute )* ( servicePart )* ) ;
    public final BlipParser.service_return service() throws RecognitionException {
        BlipParser.service_return retval = new BlipParser.service_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token type=null;
        Token name=null;
        Token LBRACE12=null;
        Token RBRACE14=null;
        BlipParser.attribute_return attribute11 = null;

        BlipParser.servicePart_return servicePart13 = null;


        Object type_tree=null;
        Object name_tree=null;
        Object LBRACE12_tree=null;
        Object RBRACE14_tree=null;
        RewriteRuleTokenStream stream_RBRACE=new RewriteRuleTokenStream(adaptor,"token RBRACE");
        RewriteRuleTokenStream stream_SERVICETYPE=new RewriteRuleTokenStream(adaptor,"token SERVICETYPE");
        RewriteRuleTokenStream stream_STRING=new RewriteRuleTokenStream(adaptor,"token STRING");
        RewriteRuleTokenStream stream_LBRACE=new RewriteRuleTokenStream(adaptor,"token LBRACE");
        RewriteRuleSubtreeStream stream_servicePart=new RewriteRuleSubtreeStream(adaptor,"rule servicePart");
        RewriteRuleSubtreeStream stream_attribute=new RewriteRuleSubtreeStream(adaptor,"rule attribute");
        try {
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:69:8: (type= SERVICETYPE name= STRING ( attribute )* LBRACE ( servicePart )* RBRACE -> ^( SERVICE $type ( attribute )* ( servicePart )* ) )
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:69:10: type= SERVICETYPE name= STRING ( attribute )* LBRACE ( servicePart )* RBRACE
            {
            type=(Token)match(input,SERVICETYPE,FOLLOW_SERVICETYPE_in_service254);  
            stream_SERVICETYPE.add(type);

            name=(Token)match(input,STRING,FOLLOW_STRING_in_service258);  
            stream_STRING.add(name);

            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:69:39: ( attribute )*
            loop5:
            do {
                int alt5=2;
                int LA5_0 = input.LA(1);

                if ( (LA5_0==AT) ) {
                    alt5=1;
                }


                switch (alt5) {
            	case 1 :
            	    // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:69:39: attribute
            	    {
            	    pushFollow(FOLLOW_attribute_in_service260);
            	    attribute11=attribute();

            	    state._fsp--;

            	    stream_attribute.add(attribute11.getTree());

            	    }
            	    break;

            	default :
            	    break loop5;
                }
            } while (true);

            LBRACE12=(Token)match(input,LBRACE,FOLLOW_LBRACE_in_service263);  
            stream_LBRACE.add(LBRACE12);

            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:69:57: ( servicePart )*
            loop6:
            do {
                int alt6=2;
                int LA6_0 = input.LA(1);

                if ( (LA6_0==STRING) ) {
                    alt6=1;
                }


                switch (alt6) {
            	case 1 :
            	    // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:69:57: servicePart
            	    {
            	    pushFollow(FOLLOW_servicePart_in_service265);
            	    servicePart13=servicePart();

            	    state._fsp--;

            	    stream_servicePart.add(servicePart13.getTree());

            	    }
            	    break;

            	default :
            	    break loop6;
                }
            } while (true);

            RBRACE14=(Token)match(input,RBRACE,FOLLOW_RBRACE_in_service268);  
            stream_RBRACE.add(RBRACE14);



            // AST REWRITE
            // elements: servicePart, attribute, type
            // token labels: type
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleTokenStream stream_type=new RewriteRuleTokenStream(adaptor,"token type",type);
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 70:2: -> ^( SERVICE $type ( attribute )* ( servicePart )* )
            {
                // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:70:5: ^( SERVICE $type ( attribute )* ( servicePart )* )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(SERVICE, "SERVICE"), root_1);

                adaptor.addChild(root_1, stream_type.nextNode());
                // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:70:21: ( attribute )*
                while ( stream_attribute.hasNext() ) {
                    adaptor.addChild(root_1, stream_attribute.nextTree());

                }
                stream_attribute.reset();
                // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:70:32: ( servicePart )*
                while ( stream_servicePart.hasNext() ) {
                    adaptor.addChild(root_1, stream_servicePart.nextTree());

                }
                stream_servicePart.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "service"

    public static class servicePart_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "servicePart"
    // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:72:1: servicePart : modelAttr ;
    public final BlipParser.servicePart_return servicePart() throws RecognitionException {
        BlipParser.servicePart_return retval = new BlipParser.servicePart_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        BlipParser.modelAttr_return modelAttr15 = null;



        try {
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:72:12: ( modelAttr )
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\parser\\BlipParser.g:72:14: modelAttr
            {
            root_0 = (Object)adaptor.nil();

            pushFollow(FOLLOW_modelAttr_in_servicePart292);
            modelAttr15=modelAttr();

            state._fsp--;

            adaptor.addChild(root_0, modelAttr15.getTree());

            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "servicePart"

    // Delegated rules


 

    public static final BitSet FOLLOW_applicationPart_in_main98 = new BitSet(new long[]{0x00000000000010C2L});
    public static final BitSet FOLLOW_attribute_in_applicationPart117 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_model_in_applicationPart125 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_service_in_applicationPart133 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_AT_in_attribute144 = new BitSet(new long[]{0x0000000000080000L});
    public static final BitSet FOLLOW_STRING_in_attribute148 = new BitSet(new long[]{0x0000000000080000L});
    public static final BitSet FOLLOW_STRING_in_attribute152 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_MINUS_in_model172 = new BitSet(new long[]{0x0000000000080000L});
    public static final BitSet FOLLOW_STRING_in_model176 = new BitSet(new long[]{0x0000000000000100L});
    public static final BitSet FOLLOW_LBRACE_in_model178 = new BitSet(new long[]{0x0000000000080200L});
    public static final BitSet FOLLOW_modelAttr_in_model180 = new BitSet(new long[]{0x0000000000080200L});
    public static final BitSet FOLLOW_RBRACE_in_model183 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_STRING_in_modelAttr213 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_COLON_in_modelAttr215 = new BitSet(new long[]{0x0000000000080000L});
    public static final BitSet FOLLOW_STRING_in_modelAttr219 = new BitSet(new long[]{0x0000000000000402L});
    public static final BitSet FOLLOW_BRACKETS_in_modelAttr224 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_SERVICETYPE_in_service254 = new BitSet(new long[]{0x0000000000080000L});
    public static final BitSet FOLLOW_STRING_in_service258 = new BitSet(new long[]{0x0000000000000140L});
    public static final BitSet FOLLOW_attribute_in_service260 = new BitSet(new long[]{0x0000000000000140L});
    public static final BitSet FOLLOW_LBRACE_in_service263 = new BitSet(new long[]{0x0000000000080200L});
    public static final BitSet FOLLOW_servicePart_in_service265 = new BitSet(new long[]{0x0000000000080200L});
    public static final BitSet FOLLOW_RBRACE_in_service268 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_modelAttr_in_servicePart292 = new BitSet(new long[]{0x0000000000000002L});

}